
package Gui;

import Oracle.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Alonso
 */
public class GastosGUI extends javax.swing.JDialog {
    
    private String kiosco = "";
    private SimpleDateFormat fecha = new SimpleDateFormat("dd/MM/yyyy");

    /** Creates new form GastosGUI */
    public GastosGUI(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    public GastosGUI(java.awt.Frame parent, boolean modal,String kiosco) throws SQLException {
        super(parent, modal);
        initComponents();
        this.kiosco = kiosco;
        llenarTablaGasto();
    }
    
    private void llenarTablaGasto() throws SQLException {
        
        DefaultTableModel direcTable = new DefaultTableModel();
        direcTable.addColumn("ID");
        direcTable.addColumn("Fecha");
        
        Connection con = OracleMethods.oracleConnection();
        Statement sentencia = con.createStatement();  
        ResultSet direcSet = sentencia.executeQuery("SELECT * FROM ao_gasto WHERE kiosco_pk_fk = '" + kiosco + "'");
        
         while(direcSet.next()) { 
            Vector row = new Vector();
            row.add(direcSet.getString("gasto_pk"));
            row.add(direcSet.getString("fecha"));
            direcTable.addRow(row);
         }
            
            this.tableGasto.setModel(direcTable);
            this.tableGasto.setVisible(true);
            
            sentencia.close();
            direcSet.close(); 
            con.close();
    }
    
    private void limpiarTextsGasto(){
        fechaGasto.setDate(null);
        textIdGasto.setText("");
        textMontoGasto.setText("");
        textTipoGasto.setText("");
    }
    
    private boolean camposVaciosGasto(){
        if(fechaGasto.getDate() == null || textMontoGasto.getText().isEmpty() || textTipoGasto.getText().isEmpty()  ){
            JOptionPane.showMessageDialog(this, "Llene los campos vacios");
            return true;
        }
        else
            return false;
            
    }
   

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        textIdGasto = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        textTipoGasto = new javax.swing.JTextField();
        textMontoGasto = new javax.swing.JTextField();
        fechaGasto = new com.toedter.calendar.JDateChooser();
        jButton1 = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        buttonRegistrarGasto = new javax.swing.JButton();
        buttonEditarGasto = new javax.swing.JButton();
        buttonBorrarGasto = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        tableGasto = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Gastos");

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Detalles"));

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel12.setText("ID Number");

        textIdGasto.setEditable(false);
        textIdGasto.setText("--");

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel13.setText("Fecha");

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel14.setText("Tipo");

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel15.setText("Monto");

        textTipoGasto.setEditable(false);
        textTipoGasto.setText("--");
        textTipoGasto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                textTipoGastoMouseClicked(evt);
            }
        });
        textTipoGasto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textTipoGastoActionPerformed(evt);
            }
        });

        textMontoGasto.setEditable(false);
        textMontoGasto.setText("--");
        textMontoGasto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                textMontoGastoMouseClicked(evt);
            }
        });
        textMontoGasto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textMontoGastoActionPerformed(evt);
            }
        });

        fechaGasto.setDateFormatString("dd-MM-yyyy");

        jButton1.setText("Cancelar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel14)
                            .addComponent(jLabel15)
                            .addComponent(jLabel13))
                        .addGap(13, 13, 13)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textTipoGasto, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                            .addComponent(textIdGasto, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                            .addComponent(textMontoGasto, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                            .addComponent(fechaGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textIdGasto)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
                    .addComponent(fechaGasto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(textTipoGasto))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(textMontoGasto))
                .addGap(142, 142, 142)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        buttonRegistrarGasto.setFont(new java.awt.Font("Tahoma", 0, 13));
        buttonRegistrarGasto.setText("Registrar");
        buttonRegistrarGasto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonRegistrarGastoActionPerformed(evt);
            }
        });

        buttonEditarGasto.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N
        buttonEditarGasto.setText("Editar");
        buttonEditarGasto.setEnabled(false);
        buttonEditarGasto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonEditarGastoActionPerformed(evt);
            }
        });

        buttonBorrarGasto.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N
        buttonBorrarGasto.setText("Borrar");
        buttonBorrarGasto.setEnabled(false);
        buttonBorrarGasto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonBorrarGastoActionPerformed(evt);
            }
        });

        tableGasto.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "ID", "Fecha"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tableGasto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableGastoMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(tableGasto);

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, 0, 0, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                        .addComponent(buttonRegistrarGasto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonEditarGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonBorrarGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonRegistrarGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonEditarGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonBorrarGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void textTipoGastoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_textTipoGastoMouseClicked

}//GEN-LAST:event_textTipoGastoMouseClicked

private void textTipoGastoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textTipoGastoActionPerformed
    
}//GEN-LAST:event_textTipoGastoActionPerformed

private void buttonRegistrarGastoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRegistrarGastoActionPerformed
if(buttonRegistrarGasto.getText().equals("Registrar")){
    //Desactivamos la navegacion a otras pantallas, botones y activamos los texts
    tableGasto.setEnabled(false);
    fechaGasto.setEnabled(true);
    textTipoGasto.setEditable(true);
    textMontoGasto.setEditable(true);
    buttonRegistrarGasto.setText("Confirmar");
    buttonEditarGasto.setEnabled(false);
    buttonBorrarGasto.setEnabled(false);
    limpiarTextsGasto();       
}
else{  
    if(camposVaciosGasto())
        return;

    try{
    Connection con = OracleMethods.oracleConnection();
    Statement sentencia = con.createStatement(); 
    sentencia.executeQuery("INSERT INTO ao_gasto (gasto_pk, fecha, tipo, monto, kiosco_pk_fk) "
                            + "VALUES ("
                            + " gasto_pk.nextval,"
                            + "'" + fecha.format(fechaGasto.getDate()) + "' ,"
                            + "'" + textTipoGasto.getText() + "' ,"
                            + "" + textMontoGasto.getText() + " ,"
                            + "" + kiosco + ")");
    
    sentencia.close();
    con.close();
                          
    }
    catch(SQLException ex){
        System.out.println("SQL error");
        JOptionPane.showMessageDialog(this, "Introduzca una fecha con el siguiente formato dd/mm/aaaa");
        Logger.getLogger(GastosGUI.class.getName()).log(Level.SEVERE, null, ex);
        return;
    }
    
    //Activamos la navegacion a otras pantallas, botones y desactivamos los texts
    tableGasto.setEnabled(true);
    fechaGasto.setEnabled(false);
    textTipoGasto.setEditable(false);
    textMontoGasto.setEditable(false);
    buttonRegistrarGasto.setText("Registrar");
    buttonEditarGasto.setEnabled(true);
    buttonBorrarGasto.setEnabled(true);
    
    JOptionPane.showMessageDialog(this, "Registro Exitoso");
    try {
        llenarTablaGasto();
    } catch (SQLException ex) {
        Logger.getLogger(GastosGUI.class.getName()).log(Level.SEVERE, null, ex);
    }
   
}   
}//GEN-LAST:event_buttonRegistrarGastoActionPerformed

private void buttonEditarGastoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEditarGastoActionPerformed
if(buttonEditarGasto.getText().equals("Editar")){
    //Desactivamos la navegacion a otras pantallas, botones y activamos los texts
    tableGasto.setEnabled(false);
    fechaGasto.setEnabled(true);
    textTipoGasto.setEditable(true);
    textMontoGasto.setEditable(true);
    buttonEditarGasto.setText("Confirmar");
    buttonRegistrarGasto.setEnabled(false);
    buttonBorrarGasto.setEnabled(false);    
}
else{  
    if(camposVaciosGasto())
        return;

    try{
    Connection con = OracleMethods.oracleConnection();
    Statement sentencia = con.createStatement();  
    sentencia.executeQuery("UPDATE ao_gasto SET "
                            + "fecha = '" + fecha.format(fechaGasto.getDate()) + "' ,"
                            + "tipo = '" + textTipoGasto.getText() + "' ,"
                            + "monto = '" + textMontoGasto.getText() + "' "
                            + "WHERE gasto_pk = '" + textIdGasto.getText() + "'");
    
    sentencia.close();
    con.close();
                         
    }
    catch(SQLException ex){
        System.out.println("SQL error");
        JOptionPane.showMessageDialog(this, "Introduzca una fecha con el siguiente formato dd/mm/aaaa");
        Logger.getLogger(BaseDatosGUI.class.getName()).log(Level.SEVERE, null, ex);
        return;
    }
    
    //Activamos la navegacion a otras pantallas, botones y desactivamos los texts
    tableGasto.setEnabled(true);
    fechaGasto.setEnabled(false);
    textTipoGasto.setEditable(false);
    textMontoGasto.setEditable(false);
    buttonEditarGasto.setText("Editar");
    buttonRegistrarGasto.setEnabled(true);
    buttonBorrarGasto.setEnabled(true);
    
    JOptionPane.showMessageDialog(this, "Edicion Exitosa");
    try {
        llenarTablaGasto();
    } catch (SQLException ex) {
        Logger.getLogger(BaseDatosGUI.class.getName()).log(Level.SEVERE, null, ex);
    }
   
}   
}//GEN-LAST:event_buttonEditarGastoActionPerformed

private void buttonBorrarGastoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBorrarGastoActionPerformed
int confirmacion = JOptionPane.showConfirmDialog(this, "¿Desea borrar el gasto?");

if(confirmacion == 0){
    try {
        Connection con = OracleMethods.oracleConnection();
        Statement sentencia = con.createStatement(); 
        sentencia.executeQuery("DELETE FROM ao_gasto WHERE gasto_pk = '" + textIdGasto.getText() + "'");
        limpiarTextsGasto();
        llenarTablaGasto();
        
        sentencia.close();
        con.close();
        
    } catch (SQLException ex) {
        Logger.getLogger(BaseDatosGUI.class.getName()).log(Level.SEVERE, null, ex);
    }   
}
}//GEN-LAST:event_buttonBorrarGastoActionPerformed

private void tableGastoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableGastoMouseClicked
if(!tableGasto.isEnabled())
    return;
    
    int row = this.tableGasto.getSelectedRow();
    String id = (String) this.tableGasto.getModel().getValueAt(row, 0).toString();
    ResultSet direcSet = null;
    this.buttonBorrarGasto.setEnabled(true);
    this.buttonEditarGasto.setEnabled(true);
     
    try {
        
    Connection con = OracleMethods.oracleConnection();
    Statement sentencia = con.createStatement(); 
    direcSet = sentencia.executeQuery("SELECT * FROM ao_gasto WHERE gasto_PK =" + id); 
    
    if(direcSet.next()){
        textIdGasto.setText(direcSet.getString("gasto_pk"));
        fechaGasto.setDate(direcSet.getDate("fecha"));
        textTipoGasto.setText(direcSet.getString("tipo"));
        textMontoGasto.setText(direcSet.getString("monto"));
    }
    
    sentencia.close();
    direcSet.close();
    con.close();
    
    } catch (SQLException ex) {
        Logger.getLogger(BaseDatosGUI.class.getName()).log(Level.SEVERE, null, ex);
    }
}//GEN-LAST:event_tableGastoMouseClicked

private void textMontoGastoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_textMontoGastoMouseClicked
// TODO add your handling code here:
}//GEN-LAST:event_textMontoGastoMouseClicked

private void textMontoGastoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textMontoGastoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_textMontoGastoActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    this.dispose();
}//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GastosGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GastosGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GastosGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GastosGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                GastosGUI dialog = new GastosGUI(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonBorrarGasto;
    private javax.swing.JButton buttonEditarGasto;
    private javax.swing.JButton buttonRegistrarGasto;
    private com.toedter.calendar.JDateChooser fechaGasto;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTable tableGasto;
    private javax.swing.JTextField textIdGasto;
    private javax.swing.JTextField textMontoGasto;
    private javax.swing.JTextField textTipoGasto;
    // End of variables declaration//GEN-END:variables
}
